const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const pkg = require('./package.json');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  mode: 'production',
  entry: {
    'index': './src/index.js',
    'crud-element-ui': './src/crud-element-ui.js',
  },
  externals: /^(@holyhigh.+)$/i,
  output: {
    clean: true,
    filename: '[name].js',
    path: __dirname + '/dist',
    library: {
      name: 'CRUD',
      type: 'umd',
      export: 'default',
      umdNamedDefine: true,
    },
  },
  plugins: [
    new webpack.BannerPlugin({
      banner: `CRUD-Vue v${pkg.version}\n@${pkg.author}\n${pkg.repository.url}
        `,
      entryOnly: false,
    }),
    new CopyPlugin({
      patterns: [
        './package.json',
        './LICENSE',
        './README.md',
      ],
    }),
  ],
  optimization: {
    minimizer: [new TerserPlugin({
      extractComments: false,
    })],
  },
};
